<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue的依赖收集&&响应式原理</title>
</head>
<body>
    
    <span>
        count: <span id="count"></span>
    </span>
    <br/>
    <button id="btn1">count+1</button>
</body>
</html>

<script src="./dep.js"></script>
<script src="./watcher.js"></script>
<script src="./observer.js"></script>

<script>

    let obj = {count: 1} 
    observe(obj)
    
    function renderCountSpan() {
        let dom = document.querySelector('#count')
        dom.textContent = obj.count
    }
    
    let watcher = new Watcher(() => renderCountSpan())
    
    // 点击事件
    let btn1 = document.querySelector('#btn1')
    btn1.addEventListener('click', function() {
        obj.count++
    })

</script>